package com.wskj.library.employer.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wskj.library.pojo.Employer;
import com.wskj.library.service.EmployerService;
import com.wskj.library.service.impl.EmployerServiceImpl;
import com.wskj.util.Page;
import com.wskj.util.StringUtil;

/**
 * @author 胡洋
 * @describe 
 * @Date 2018年3月22日下午6:11:24
 * @version 1.0
 */
@WebServlet(urlPatterns="/employer/list.do")
public class EmployerListServlet extends HttpServlet {
	 EmployerService  emService=new EmployerServiceImpl(); 
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		int index =StringUtil.nullToInt(req.getParameter("pageIndex"));
		String name = StringUtil.nullToString(req.getParameter("uname"));
		String phone = StringUtil.nullToString(req.getParameter("phone"));
		String birthday =StringUtil.nullToString(req.getParameter("birthday"));		
		
		Page<Employer> page=new Page<Employer>(index,10);		
		long counts=emService.getCountsByName(name,phone,birthday);
		page.setPageIndex(index);
		page.setCounts(counts);
		List<Employer> employers=emService.queryEmployers(name,phone,birthday,index,page.getPageSize());
		page.setData(employers);
		
		req.setAttribute("page", page);
		req.getRequestDispatcher("/WEB-INF/page/employer/list.jsp").forward(req, resp);
		
	}

}
